package b.b.g;

import android.content.Context;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import androidx.appcompat.widget.ActionBarContextView;
import androidx.appcompat.widget.ActionMenuPresenter;
import b.b.g.i.g;
import b.b.g.i.g.a;
import java.lang.ref.WeakReference;

/* compiled from: StandaloneActionMode */
public class d extends a implements a {
    public Context c;
    public ActionBarContextView d;
    public a.a e;
    public WeakReference<View> f;
    public boolean g;
    public g h;

    public d(Context context, ActionBarContextView actionBarContextView, a.a aVar, boolean z) {
        this.c = context;
        this.d = actionBarContextView;
        this.e = aVar;
        g gVar = new g(actionBarContextView.getContext());
        this.h = gVar;
        gVar.e = this;
    }

    public boolean a(g gVar, MenuItem menuItem) {
        return this.e.c(this, menuItem);
    }

    public void b(g gVar) {
        i();
        ActionMenuPresenter actionMenuPresenter = this.d.d;
        if (actionMenuPresenter != null) {
            actionMenuPresenter.n();
        }
    }

    public void c() {
        if (!this.g) {
            this.g = true;
            this.d.sendAccessibilityEvent(32);
            this.e.b(this);
        }
    }

    public View d() {
        WeakReference weakReference = this.f;
        return weakReference != null ? (View) weakReference.get() : null;
    }

    public Menu e() {
        return this.h;
    }

    public MenuInflater f() {
        return new f(this.d.getContext());
    }

    public CharSequence g() {
        return this.d.getSubtitle();
    }

    public CharSequence h() {
        return this.d.getTitle();
    }

    public void i() {
        this.e.a(this, this.h);
    }

    public boolean j() {
        return this.d.r;
    }

    public void k(View view) {
        this.d.setCustomView(view);
        this.f = view != null ? new WeakReference(view) : null;
    }

    public void l(int i) {
        this.d.setSubtitle(this.c.getString(i));
    }

    public void m(CharSequence charSequence) {
        this.d.setSubtitle(charSequence);
    }

    public void n(int i) {
        this.d.setTitle(this.c.getString(i));
    }

    public void o(CharSequence charSequence) {
        this.d.setTitle(charSequence);
    }

    public void p(boolean z) {
        this.b = z;
        this.d.setTitleOptional(z);
    }
}
